﻿claim_throne_setup = {
	effect = {
		add_character_flag = {
			flag = is_executing_claim_throne
			days = 365
		}
	}
	first_valid_on_action = {
		standard_claim_throne_method_setup
	}
}



standard_claim_throne_method_setup = {
	random_events = {
		200 = claim_throne_outcome.1001 # Distant relation
		200 = claim_throne_outcome.1002 # Mythical Founder
		#100 = claim_throne_outcome.1003 # Previous Holder Promise
	}
}

claim_throne_succeeded = {
	# Picks out the correct success event depending on setup.
	first_valid = {
		claim_throne_outcome.2001 #Distant relation
		claim_throne_outcome.2002 # Mythical Founder
		#claim_throne_outcome.2003 # Previous Holder Promise
	}
	effect = {
		shogunate_check_catalyst_shogunate_claim_throne_effect = yes

		add_achievement_flag_effect = { FLAG = achievement_not_so_feudal_system_flag }
		remove_character_flag = is_executing_claim_throne
	}
}

claim_throne_failed = {
	# Picks out the correct failure event depending on setup/save.
	first_valid = {
		claim_throne_outcome.4001 #Distant relation
		claim_throne_outcome.4002 # Mythical Founder
		#claim_throne_outcome.4003 # Previous Holder Promise
	}
}

claim_throne_ongoing = {
	trigger = {
		exists = scope:scheme
		# None of the events here are fitting for if you as the scheme owner are traveling, so we block them, especially since their chance to happen is so low anyway
		is_travelling = no
	}
	# Events that can happen while Claiming Throne from your Liege
	random_events = {
		chance_to_happen = 5
		100 = claim_throne_ongoing.1001 # Liege suffers ill omens
		100 = claim_throne_ongoing.1002 # Take on more responsibility
		100 = claim_throne_ongoing.1003 # Buy support from fellow vassals
		100 = claim_throne_ongoing.1004 # Lunatic takes it by confidence alone
		100 = claim_throne_ongoing.1006 # Friend swears they will support your claim
		100 = claim_throne_ongoing.1007 # Get a knight on your side.
		100 = claim_throne_ongoing.1008 # Use trickery.
		50 = 0

		#############
		# Generic Agent events
		#############

		500 = agent_events.9801				# Wrapper event for general agent events on_action.
	}
}
